{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "induced-orleans",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.linear_model import LinearRegression \n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "from sklearn.metrics import mean_squared_error,r2_score\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "pediatric-tower",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>speed</th>\n",
       "      <th>price</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>9</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>9</td>\n",
       "      <td>22.97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>25.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>9</td>\n",
       "      <td>25.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>9</td>\n",
       "      <td>26.31</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  speed  price\n",
       "0     9  22.97\n",
       "1     9  22.97\n",
       "2     9  25.23\n",
       "3     9  25.23\n",
       "4     9  26.31"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "# 读取数据\n",
    "data = pd.read_csv(\"./data/finalPrice_100kmAcceleration.csv\")\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "comparative-drama",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(14839, 2)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "confirmed-logistics",
   "metadata": {},
   "outputs": [],
   "source": [
    "data['speed'] = data['speed'].str.replace(\"-\",\"0\").astype('float64')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "miniature-compound",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 14839 entries, 0 to 14838\n",
      "Data columns (total 2 columns):\n",
      " #   Column  Non-Null Count  Dtype  \n",
      "---  ------  --------------  -----  \n",
      " 0   speed   14839 non-null  float64\n",
      " 1   price   14839 non-null  float64\n",
      "dtypes: float64(2)\n",
      "memory usage: 232.0 KB\n"
     ]
    }
   ],
   "source": [
    "data.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "intermediate-marble",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEGCAYAAACUzrmNAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAY8klEQVR4nO3df5BlZX3n8fd3fkXGbBxm6LAww8yQlWjQGIQuIKW1m2VWGNFkqF3LH2lkImQny1guViVl0NkqKurUalIVhCo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HAXcEo5o2EF8Hbg1j63aRDcCmwt01uBW/rYlp4px6CvA+7NzD9vW7RYt8dQRKwq08cAb6Dqx7kTeEtZbVFsj8x8f2auy8yNVN8Td2TmCAt8W3gFd5vyl8LHgKXA9Zm5s78t6q2I+Bvgt6iGWv4RcAXwX4CbgfVUw76/NTOP7ARfcCLi9cBXgHuYOC79Aap+i8W4PV5D1Wm7lOqPzJsz84MR8StUJ4OsBu4GLszMZ/rX0t6KiN8C/igz37zQt4VhIUmq5WEoSVItw0KSVMuwkCTVMiwkSbUMC0lSLcNCGnAR8XcRMdzvdmhxMywkSbUMC2kOIuKlEfHfyv0dvhMRb4uIByLiTyPinnLvh5eXdYci4jMRcVd5vK7tPa4v694dEVtK/ZiIuCki7o2IzwHH9PFHlQDHhpLmajPwSGa+CSAiXkZ1P4MnM/PXI+IiqtEA3kw1btCVmfm/ImI98AXg14AdVENFXFyG0vh6RHwJ+APgUGb+Wrly+hs9/tmko3gFtzQHEfGrwBeBTwGfz8yvRMQDVDcI+n4ZhPCHmbkmIvYDj7S9fAh4BfB3VAPRtYa1Xg2cB/xH4OrMvKN81jeAbZk53vxPJk3NPQtpDjLz/0bE6cD5wIcj4vbWovbVyvMS4OzM/Fn7e5TBCv9NZt53RL2hVktzZ5+FNAcRcSLVoaIbgT8DTi+L3tb2/A9l+ovAe9pee1qZ/ALwnhIaRMRrS/3LwO+W2quB1zTzU0idc89CmptfB/4sIl4AngMupbql5rER8W2qe1a/o6z774GPl/oyqjD4d8CHqPo1vh0RS4AfUPVxXAv8p4i4l2oY8EV1kx0NJvsspC4pfRbDmfnjfrdF6jYPQ0mSarlnIUmq5Z6FJKmWYSFJqmVYSJJqGRaSpFqGhSSp1v8HcGTIstj/wqgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#绘制散点图\n",
    "plt.scatter(data.speed,data.price,color = 'b',label = \"Exam Data\")\n",
    " \n",
    "#添加图的标签（x轴，y轴）\n",
    "plt.xlabel(\"speed\")\n",
    "plt.ylabel(\"price\")\n",
    "#显示图像\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "spread-drawing",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始数据特征: (14839,) ,训练数据特征: (11871,) ,测试数据特征: (2968,)\n",
      "原始数据标签: (14839,) ,训练数据标签: (11871,) ,测试数据标签: (2968,)\n"
     ]
    }
   ],
   "source": [
    "exam_X = data['speed']\n",
    "exam_Y = data['price']\n",
    "#将原数据集拆分训练集和测试集\n",
    "X_train,X_test,Y_train,Y_test = train_test_split(exam_X,exam_Y,train_size=.8)\n",
    "#X_train为训练数据标签,X_test为测试数据标签,exam_X为样本特征,exam_y为样本标签，train_size 训练数据占比\n",
    " \n",
    "print(\"原始数据特征:\",exam_X.shape,\n",
    "      \",训练数据特征:\",X_train.shape,\n",
    "      \",测试数据特征:\",X_test.shape)\n",
    " \n",
    "print(\"原始数据标签:\",exam_Y.shape,\n",
    "      \",训练数据标签:\",Y_train.shape,\n",
    "      \",测试数据标签:\",Y_test.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "noticed-world",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "LinearRegression()"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model = LinearRegression()\n",
    "\n",
    "X_train = X_train.values.reshape(-1,1)\n",
    "X_test = X_test.values.reshape(-1,1)\n",
    " \n",
    "model.fit(X_train,Y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "dominican-nothing",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "最佳拟合线:截距 21.188501185450704 ,回归系数： [1.68548043]\n"
     ]
    }
   ],
   "source": [
    "a  = model.intercept_#截距\n",
    " \n",
    "b = model.coef_#回归系数\n",
    " \n",
    "print(\"最佳拟合线:截距\",a,\",回归系数：\",b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "direct-treaty",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEJCAYAAABlmAtYAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuMywgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/Il7ecAAAACXBIWXMAAAsTAAALEwEAmpwYAAAlKklEQVR4nO3deZhddZ3n8fcnRRZLMIEi+tAJqYpOQMKWkIIRlG6iYiLQQtsuYKEZXGJYbLQdBBq6WWbyjI7abG2ChSBgCsRJ6whtFGhHxG5aoYIxhLAkQBIS0lAECEsIWeo7f5xzk1uVu9Ryt6r7eT3Pee4933PuuT8OqfO9v+X8jiICMzOzQkZUuwBmZlb7nCzMzKwoJwszMyvKycLMzIpysjAzs6KcLMzMrKiyJQtJN0l6QdKKrNgdkpalyxpJy9J4i6Q3s7Zdn/WZGZIekbRa0rWSVK4ym5lZbnuV8dg3A/8E3JoJRMSnM+8lfRfYnLX/UxExLcdxFgJfAv4ALAFmA78sfXHNzCyfsiWLiLhfUkuubWnt4FPABwsdQ9IBwDsi4vfp+q3AafQhWey///7R0pLz683MLIelS5e+GBHjc20rZ82ikOOB5yNiVVZssqQ/Aq8Cl0bE74AJwPqsfdansZwkzQXmAkyaNInOzs6SF9zMbLiStDbftmp1cJ8B3J61vhGYFBHTgb8FbpP0jv4eNCLaI6I1IlrHj8+ZHM3MbAAqXrOQtBfwcWBGJhYRbwFvpe+XSnoKOAjYAEzM+vjENGZmZhVUjZrFh4HHI2JX85Kk8ZIa0vfvBqYAT0fERuBVSe9L+zk+B/y8CmU2M6trZatZSLodOAHYX9J64LKIuBE4nZ5NUAB/DlwpaTvQDcyLiJfSbeeQjKx6G0nH9oBHQm3fvp3169ezdevWgR6ibo0ZM4aJEycycuTIahfFzKpAw3WK8tbW1ujdwf3MM8+wzz770NTUhG/X6LuIYNOmTbz22mtMnjy52sUxszKRtDQiWnNtq9ZoqKrYunUrLS0t1UkUmzbBhg2wbRuMGgUTJkBTU+XLMQCSaGpqoqurq9pFMbMqqatkAVQvUaxdC93dyfq2bck6DKmEYWb1y3NDVcKGDbsTRUZ3dxI3MxsCnCwqYds2ANY89xyHffrTe8T767777uOBBx7Iue3mm2/mvPPOA+D666/n1ltvzbmfmVl/1F0zVFWMGpU7MYwaNaDD3Xfffey9994cd9xxBfebN2/egI5vZtabaxaVMGECjEhO9Y6dO2m79FIO+eQn+cSll7JlyxYAli5dyl/8xV8wY8YMZs2axcaNGwG49tprmTp1KkcccQSnn346a9as4frrr+eqq65i2rRp/O53v8v7tZdffjnf+c53ADjhhBO48MILOeaYYzjooIN2fW7nzp1ccMEFHH300RxxxBF8//vfL+eZMLMhqm6ThaSyLXtoaoLmZhg5kifWruWcM87gsc5O3rH//ixYsIDt27fzla98hcWLF7N06VI+//nPc8kllwDwzW9+kz/+8Y8sX76c66+/npaWFubNm8fXvvY1li1bxvHHH9/n/+YdO3bw4IMPcvXVV3PFFVcAcOONNzJ27FgeeughHnroIW644QaeeeaZkpxjMxs+3AxVKU1NcMghHHjggbx/zhwAzjzzTK699lpmz57NihUrOPHEE4Hk1/4BBxwAwBFHHEFbWxunnXYap5122qCK8PGPfxyAGTNmsGbNGgDuueceli9fzuLFiwHYvHkzq1at8v0UZtaDk0WF9a55SCIiOPTQQ/mP//iPPfb/xS9+wf33389dd93F/PnzeeSRRwb83aNHjwagoaGBHTt2AMkNd9dddx2zZs0a8HHNbPir22aoiCjbUsi6det2JYXbbruND3zgAxx88MF0dXXtim/fvp1HH32U7u5unn32WWbOnMm3vvUtNm/ezOuvv84+++zDa6+9VpLzMGvWLBYuXMj27dsBePLJJ3njjTdKcmwzGz7qNllUy8EHH8z3vvc9DjnkEF5++WXOPvtsRo0axeLFi7nwwgs58sgjmTZtGg888AA7d+7kzDPP5PDDD2f69On8zd/8DePGjeMv//Iv+dnPfla0g7svvvjFLzJ16lSOOuooDjvsML785S/vqnWYmWXU1dxQjz32GIccckiVSjT0+fyZDW+F5oZyzcLMzIpysjAzs6KcLMzMrCgnCzMzK8rJwszMinKyMDOzopwsKuiVV15hwYIFA/781VdfvWviwULuu+8+TjnllIL7LFu2jCVLlgy4LGZWX5wsKqhSyaIvnCzMrD+cLArp6ICWlmR68ZaWZH0QLrroIp566immTZvGBRdcAMC3v/3tXdODX3bZZQC88cYbnHzyyRx55JEcdthh3HHHHVx77bU899xzzJw5k5kzZ+5x7F/96le8973v5aijjuKnP/3prviDDz7Isccey/Tp0znuuON44okn2LZtG//wD//AHXfcwbRp07jjjjty7mdmtksZ50e6CXgBWJEVuxzYACxLl5Oytl0MrAaeAGZlxWensdXARX39/hkzZkRvK1eu3COW16JFEY2NEbB7aWxM4gP0zDPPxKGHHrpr/e67744vfelL0d3dHTt37oyTTz45fvvb38bixYvji1/84q79XnnllYiIaG5ujq6urj2O++abb8bEiRPjySefjO7u7vjkJz8ZJ598ckREbN68ObZv3x4REffee298/OMfj4iIH/7wh3HuuefuOka+/bL16/yZ2ZADdEaea2o5Z529GfgnoPdzPa+KiO9kByRNBU4HDgX+DPhXSQelm78HnAisBx6SdGdErCxjuROXXAK9m3y2bEnibW0l+Yp77rmHe+65h+nTpwPw+uuvs2rVKo4//ni+/vWvc+GFF3LKKacUfWbF448/zuTJk5kyZQqQTH3e3t4OJFOOz5kzh1WrViFp14SBvfV1PzOrT2VrhoqI+4GX+rj7qcCPI+KtiHiGpBZxTLqsjoinI2Ib8ON03/Jbt65/8QGICC6++GKWLVvGsmXLWL16NV/4whc46KCDePjhhzn88MO59NJLufLKKwf8HX//93/PzJkzWbFiBXfddRdbt24d1H5mVp+q0WdxnqTlkm6StG8amwA8m7XP+jSWL56TpLmSOiV1dnV1Da6Ukyb1L94HvacWnzVrFjfddBOvv/46ABs2bOCFF17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es>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.012135722977158148\n"
     ]
    }
   ],
   "source": [
    "#训练数据的预测值\n",
    "y_train_pred = model.predict(X_train)\n",
    "#绘制最佳拟合线：标签用的是训练数据的预测值y_train_pred\n",
    "plt.plot(X_train, y_train_pred, color='black', linewidth=3, label=\"best line\")\n",
    " \n",
    "#测试数据散点图\n",
    "plt.scatter(X_test, Y_test, color='red', label=\"test data\")\n",
    " \n",
    "#添加图标标签\n",
    "plt.legend(loc=2)\n",
    "plt.xlabel(\"price\")\n",
    "plt.ylabel(\"speed\")\n",
    "#显示图像\n",
    "plt.savefig(\"lines.jpg\")\n",
    "plt.show()\n",
    " \n",
    " \n",
    "score = model.score(X_test,Y_test)\n",
    " \n",
    "print(score)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
